Skip to content

[SYCL] Differentiate install targets for clang* binaries#21598

Merged
dm-vodopyanov merged 55 commits into
intel:syclfrom
dm-vodopyanov:rename_clang_to_dpclang
Jul 10, 2026
Merged

[SYCL] Differentiate install targets for clang* binaries#21598
dm-vodopyanov merged 55 commits into
intel:syclfrom
dm-vodopyanov:rename_clang_to_dpclang

Conversation

@dm-vodopyanov

@dm-vodopyanov dm-vodopyanov commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

This PR adds the following:

  • The following symlinks in CMAKE_INSTALL_PREFIX/bin folder: dpclang, dpclang++, dpclang-cl, dpclang-cpp, dpsycl-ls, dpsycl-prof, etc. They WON'T point to real clang, clang++, etc binaries. They point to the tool below.
  • Adds a tool similar to AMD's amdllvm tool: https://github.com/ROCm/llvm-project/tree/amd-staging/clang/tools/amdllvm. It is called dpllvm. What it does - when we run dpclang++ symlink, it runs dpllvm tool. dpllvm gets "clang++" from "dpclang++" and executes clang++. The same will be with every other symlinks which start wqith dp. clang can run itself inside itself, so we need to keep the name of the binary - clang++. BTW, the same on Windows - but we will have tiny binaries dpclang, dpclang++, etc - as Windows does not support symlinks. So we will avoid renaming clang++ to dpclang++ on Windows and the size of binary distribution on Windows won't be bigger - there won't be copies of clang, clang-cl, etc binaries.
  • Adds dpllvm and dpclang, dpclang++, dpclang-cl, dpclang-cpp, dpsycl-ls, dpsycl-prof, etc. not only to CMAKE_INSTALL_PREFIX/bin but also to build/bin - and use these binaries everywhere in LIT tests (like it is already done in this PR)

Fixes #21511

This patch renames `clang`, `clang++`, `clang-c++`, `clang-cc`, `clang-cpp`,
`clang-g++`, `clang-gcc`, `clang-cl` to the same names with a prefix `dp` to make
sure the SYCL compiler package can be co-existed with the official clang
package for various Linux distributions.
@dm-vodopyanov dm-vodopyanov requested review from a team as code owners March 23, 2026 17:09
Comment thread clang/lib/Driver/ToolChains/Clang.cpp Outdated

SmallString<128> ClangPath(C.getDriver().Dir);
llvm::sys::path::append(ClangPath, "clang");
llvm::sys::path::append(ClangPath, "dpclang");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to change sycl/doc as well

@tahonermann

Copy link
Copy Markdown
Contributor

Thanks, @dm-vodopyanov. This is more change than I was expecting. How did you identify all the places to change? Trial and error by running the testsuite? Or a more systematic approach?

@dvrogozh dvrogozh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just a partial solution as it takes care to rename only clang* kind of things and leaves behind a bunch of lvm-* binaries, include/clang/, libLLVM*, etc. I would like to propose alternative solution which I hope will be easier:

  1. Change the install prefix for all the stuff borrowed from LLVM. Let default be $libdir/dpclang-MAJOR/ as that's prescribed default by File System Hierarchy Standard. This will immediately resolve all the potential conflicts with already installed LLVM.
  2. Install additional targets, symlinks with the original names likes dpclang-MAJOR

Above will create the following installation target (assuming the default for LLVM installation):

$bindir/dpclang ->$prefix/bin/dpclang-MAJOR
$bindir/dpclang-MAJOR 
....
$libdir/libsycl.so.VERSION
$libdir/dpcpp-MAJOR/bin/clang
$libdir/dpcpp-MAJOR/bin/clang++
$libdir/dpcpp-MAJOR/bin/llvm-ar
...

@sarnex

sarnex commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

I don't think this PR intended to solve the complete problem, I think it's just one piece of a larger set of changes.

If we try to implement all of those in one PR it will become huge, impossible to review, and more likely to have bugs.

@tahonermann

Copy link
Copy Markdown
Contributor

I would like to propose alternative solution which I hope will be easier

I tend to agree with @dvrogozh's alternate suggestion. What he proposes is similar to what is done for the oneAPI icx compiler distribution (that distribution puts the LLVM utilities in a compiler directory under $bindir).

@dvrogozh, could you please quote the section of the File System Hierarchy Standard that you feel justifies placing the LLVM assets under $libdir?

@dvrogozh

Copy link
Copy Markdown
Contributor

@dvrogozh, could you please quote the section of the File System Hierarchy Standard that you feel justifies placing the LLVM assets under $libdir?

It's section 4.6.1, https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s06.html:

"/usr/lib includes object files and libraries. On some systems, it may also include internal binaries that are not intended to be executed directly by users or shell scripts.

Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory."

Note that Debian's and Ubuntu's /usr/lib/x86_64-linux-gnu/ location is their own extension of the FHS /usr/lib defined in FHS, see https://wiki.ubuntu.com/MultiarchSpec.

Also, to place internal stuff to $libdir/<component>/ folder was the direction we've got from Debian/Fedora maintainers once we were packaging other projects (drivers) in these distributions.

@dm-vodopyanov dm-vodopyanov requested a review from bader as a code owner May 29, 2026 19:26
@dm-vodopyanov dm-vodopyanov changed the title [SYCL] Rename clang binaries to dpclang [SYCL] Differentiate install targets for clang* binaries May 29, 2026
@dm-vodopyanov dm-vodopyanov marked this pull request as draft May 29, 2026 19:47
@dm-vodopyanov dm-vodopyanov changed the title [SYCL] Differentiate install targets for clang* binaries [SYCL] Differentiate install targets for clang* binaries May 29, 2026
@tahonermann

Copy link
Copy Markdown
Contributor

@dm-vodopyanov, I see the changes are currently marked Linux only. Can you confirm that is just temporary? My expectation is that the new targets will be provided on Windows as well.

@sarnex

sarnex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@sarnex @bader @intel/dpcpp-clang-driver-reviewers @wenju-he @Maetveis @intel/llvm-reviewers-cuda @pbalcer - this is ready for the final review.

The structure on build/install folder now looks like this:

Linux: install-linux.txt Windows: install-windows.txt

@dm-vodopyanov Can you please update these files with your latest commit (reverting the devicelib change)? Seeing the install dirs will greatly help my ability to review, thanks

@dm-vodopyanov

dm-vodopyanov commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@sarnex @bader @intel/dpcpp-clang-driver-reviewers @wenju-he @Maetveis @intel/llvm-reviewers-cuda @pbalcer - this is ready for the final review.
The structure on build/install folder now looks like this:
Linux: install-linux.txt Windows: install-windows.txt

@dm-vodopyanov Can you please update these files with your latest commit (reverting the devicelib change)? Seeing the install dirs will greatly help my ability to review, thanks

Yes, I'm actually working on this, building LLVM locally

Upd.: updated the files

@sarnex sarnex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not an expert in this code either but overall lgtm, just some relatively minor comments

Comment thread clang/lib/Driver/ToolChains/CommonArgs.cpp Outdated
Comment thread clang/lib/Driver/Driver.cpp
/// Check "-fsycl-is-device" is passed when compiling for device:
// RUN: %clang -### -fsycl-device-only --no-offload-new-driver %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}bin{{[/\\]+}}..{{[/\\]+}}include"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what the actual change in cc1 command is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver now derives the root via findSYCLInstallRoot(D), which normalizes the path (walks up and resolves), so bin/.. is collapsed out

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thx

Comment thread clang/tools/driver/CMakeLists.txt Outdated
# actually exists rather than hardcoding a path that only works for one build
# layout.
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i dont think my previous comment is resolved, do we really need to check the entire cmake_module_path, can we just use find_file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved now, thanks

Comment thread llvm/CMakeLists.txt Outdated
# ld.lld/ld64.lld/lld-link/wasm-ld symlinks); redirect it too so the linkers
# don't collide with a system LLVM. The real lld binary destination is patched
# separately in lld/cmake/modules/AddLLD.cmake, mirroring add_clang_tool.
set(LLD_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, I'm surprised we starting seeing a collision with system lld with this PR and need a workaround, any idea why?

@dm-vodopyanov dm-vodopyanov Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These binaries were in the main bin/ folder, so I moved them to lib/dpcpp-7/bin/ folder. Saw that only on Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the install-linux.txt and install-windows.txt files, it looks like lld is only built for Windows. Is that intentional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like yes:
https://github.com/intel/llvm/blob/sycl/buildbot/configure.py#L160

    # lld is needed on Windows or when building AMDGPU

Why this is true, I have no idea.

@dm-vodopyanov dm-vodopyanov requested a review from sarnex July 7, 2026 16:12
Comment thread lld/cmake/modules/AddLLD.cmake Outdated

if (LLD_BUILD_TOOLS)
# Install the real lld binary into the versioned DPC++ tools dir (e.g.
# lib/dpcpp-N/bin) so it doesn't conflict with a system LLVM, matching

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing lld binary to lib sub-directory doesn't make sense to me. Please, fix the comment (and implementation if needed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request was to keep only DPC++-related binaries in bin/ folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, put binaries to bin sub-directory (e.g. bin/llvm-bin/).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be concerns from Canonical - "llvm-bin" is too basic name, for our compiler we need customizations. Also I don't know the whole story but looks like we can't use bin/ folder for that. So @dvrogozh suggested to use lib/dpcpp-N/bin.

+ @tahonermann for opinions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib is for libraries. bin is for binaries.
Putting binaries to lib sub-directory if we can put them into bin sub-directory doesn't make sense.
Intel oneAPI puts llvm binaries to bin/compiler directory to address the conflict with LLVM package.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to have dp* links for sycl-* tools? I don't think LLVM packages include sycl-* tools.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's useful for user experience to teach users stuff starting with dp is from intel's sycl compiler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future LLVM packages will include a sycl-ls utility. The DPC++ package that Canonical will be distributing includes the SYCL utilities with a dp prefix, so this is consistent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future LLVM packages will include a sycl-ls utility.

I'm not sure if distributing sycl-* tools as LLVM package is a good idea. I would prefer to have a separate package for them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the sycl-* utilities should be part of the LLVM project. How Linux distributors package them is up to them of course, but we can encourage them to place them in a separate package. They may opt to do so anyway. The Canonical package includes dpsycl-ls with dpclang and the other dp prefixed utilities in the dpclang package.

Comment thread cmake/Modules/GetClangResourceDir.cmake Outdated
Comment thread clang/lib/Driver/ToolChains/CommonArgs.cpp Outdated
@dm-vodopyanov dm-vodopyanov requested a review from mdtoguchi July 7, 2026 16:59
Comment thread clang/lib/Driver/ToolChains/SYCL.cpp Outdated
Comment thread clang/lib/Driver/ToolChains/SYCL.cpp Outdated

@wenju-he wenju-he left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libclc change LGTM

@bratpiorka bratpiorka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CUDA LGTM

@dm-vodopyanov dm-vodopyanov requested a review from a team as a code owner July 10, 2026 15:34
@dm-vodopyanov dm-vodopyanov requested review from bader and mdtoguchi July 10, 2026 15:38

@sarnex sarnex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just one comment, nice!

Comment thread clang/tools/dpllvm/dpllvm.cpp Outdated
@dm-vodopyanov

Copy link
Copy Markdown
Contributor Author

Failure in SYCL Benchmarks is unrelated: #22599

@bader bader dismissed their stale review July 10, 2026 17:31

No more changes in upstream files -> I'm happy.

@dm-vodopyanov

Copy link
Copy Markdown
Contributor Author

All failures are unrelated to this patch:

SYCL :: KernelAndProgram/level-zero-static-link-flow.cpp - #22192
Hang tests - #22601

@dm-vodopyanov dm-vodopyanov merged commit 328217f into intel:sycl Jul 10, 2026
48 of 53 checks passed
dm-vodopyanov added a commit that referenced this pull request Jul 10, 2026
…22603)

This PR adds the following:
* The following symlinks in `CMAKE_INSTALL_PREFIX/bin` folder:
`dpclang`, `dpclang++`, `dpclang-cl`, `dpclang-cpp`, `dpsycl-ls`,
`dpsycl-prof`, etc. They WON'T point to real `clang`, `clang++`, etc
binaries. They point to the tool below.
* Adds a tool similar to AMD's `amdllvm` tool:
https://github.com/ROCm/llvm-project/tree/amd-staging/clang/tools/amdllvm.
It is called `dpllvm`. What it does - when we run `dpclang++` symlink,
it runs `dpllvm` tool. `dpllvm` gets "clang++" from "dpclang++" and
executes `clang++`. The same will be with every other symlinks which
start wqith `dp`. `clang` can run itself inside itself, so we need to
keep the name of the binary - `clang++`. BTW, the same on Windows - but
we will have tiny binaries `dpclang`, `dpclang++`, etc - as Windows does
not support symlinks. So we will avoid renaming `clang++` to `dpclang++`
on Windows and the size of binary distribution on Windows won't be
bigger - there won't be copies of `clang`, `clang-cl`, etc binaries.
* Adds `dpllvm` and `dpclang`, `dpclang++`, `dpclang-cl`, `dpclang-cpp`,
`dpsycl-ls`, `dpsycl-prof`, etc. not only to `CMAKE_INSTALL_PREFIX/bin`
but also to `build/bin` - and use these binaries everywhere in LIT tests
(like it is already done in this PR)

Fixes #21511

---------

---------

Co-authored-by: dmitry.vodopyanov <dvodopya@smtp.igk.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Differentiate install targets from CLANG and ICX